package com.hu.zhcc.shiro.service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.hu.zhcc.shiro.dao.Tj_TDiseaseLibraryMapper;
import com.hu.zhcc.shiro.entity.tj.TDiseaseLibrary;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 疾病库 服务实现类
 * </p>
 *
 * @author tj
 * @since 2021-06-24
 */
@Service
public class Tj_TDiseaseLibraryServiceImpl extends ServiceImpl<Tj_TDiseaseLibraryMapper, TDiseaseLibrary> implements Tj_TDiseaseLibraryService {
    @Autowired
    private Tj_TDiseaseLibraryMapper tjTDiseaseLibraryMapper;
    @Override
    public List<TDiseaseLibrary> queryAll() {
        return tjTDiseaseLibraryMapper.queryAll();
    }

    @Override
    public TDiseaseLibrary queryById(int id) {
        return tjTDiseaseLibraryMapper.queryById(id);
    }

    @Override
    public int addTdisease(TDiseaseLibrary tDiseaseLibrary) {
        String s = String.valueOf(Integer.parseInt(tjTDiseaseLibraryMapper.QueryCode())+1);;
        tDiseaseLibrary.setCode("JB000"+s);
        tDiseaseLibrary.setAdvise("根据医生提供的治疗方案执行");
        Date today = new Date(System.currentTimeMillis());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = simpleDateFormat.format(today);
        tDiseaseLibrary.setCreateTime(date);
        System.out.println(date);
        return tjTDiseaseLibraryMapper.addTdisease(tDiseaseLibrary);
    }

    @Override
    public int updTdisease(TDiseaseLibrary tDiseaseLibrary) {
        Date today = new Date(System.currentTimeMillis());
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String date = simpleDateFormat.format(today);
        tDiseaseLibrary.setUpdateTime(date);
        return tjTDiseaseLibraryMapper.updTdisease(tDiseaseLibrary);
    }
}
